# Contributor: Evan Johnston <evan@d2evs.net>
# Maintainer: Evan Johnston <evan@d2evs.net>
pkgname=interception-tools
pkgver=0.6.8
pkgrel=2
pkgdesc="Minimal composable infrastructure on top of libudev and libevdev"
url="https://gitlab.com/interception/linux/tools"
arch="all"
license="GPL-3.0-only"
makedepends="
	boost-dev
	cmake
	eudev-dev
	libevdev-dev
	samurai
	yaml-cpp-dev
	"
subpackages="$pkgname-openrc"
source="https://gitlab.com/interception/linux/tools/-/archive/v$pkgver/tools-v$pkgver.tar.gz
	udevmon.initd
	modules-load.conf
	"
builddir="$srcdir/tools-v$pkgver"
options="!check" # no tests

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		$crossopts
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm755 "$srcdir"/udevmon.initd \
		"$pkgdir"/etc/init.d/udevmon
	install -Dm755 "$srcdir"/modules-load.conf \
		"$pkgdir"/usr/lib/modules-load.d/$pkgname.conf
}
sha512sums="
1d156641e3457624fc24e813eecd376f16b5537b56ad9ab3df36d94a3658d905d09ec2481bc0cf29e5ef1141c363f34c691295c2a70c982648713365d17fb1be  tools-v0.6.8.tar.gz
727fe6fa86b9e862a14c03a0bec3cb361147e55cd327cb98ec75d0ab67c040f895d00153015beac1259df4557549c2efef0a4251eb8d153fd07c0df90f181d61  udevmon.initd
a9b069ed121ffeee887e0583d8cb46035ecf1fa90a26a4ecb3aa11ff03178b2b08621f6676db6b2350f290694c04aabcf36f2ce3e0813a76dde9a33555edb112  modules-load.conf
"
